import { WeaBrowser, WeaSelect, WeaLocaleProvider } from 'ecCom';
import { HtmlType } from "../../../../constants/excel";
const getLabel = WeaLocaleProvider.getLabel;


export default class FieldType extends React.Component {
    render() {
        const { htmlType } = this.props;
        if (htmlType === HtmlType.Input || htmlType === HtmlType.Browser || htmlType === HtmlType.Upload) {
            return (
                <div className="ant-row">
                    <label>{getLabel('514587','数据类型')}</label>
                    {this.getSelect(this.props)}
                </div>
            );
        }
        return null;
    }
    getSelect = ({ htmlType, ...props }) => {
        if (htmlType === HtmlType.Input) {
            return (
                <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@nz6t56`}
                    options={[{
                        key: 'text',
                        showname: getLabel('521550','单行文本')//getLabel('508622','文本')
                    },{
                        key: 'longText',
                        showname: getLabel('521551','多行文本')
                    },{
                        key: 'int',
                        showname: getLabel('508623','整数')
                    }, {
                        key: 'float',
                        showname: getLabel('508624','浮点数')
                    }]}
                    {...props}
                />
            )
        } else if (htmlType === HtmlType.Browser) {
            const { style, value, disabled, ...restProps } = props;
            if(value.value==='fieldCommonCheck' || value.value === 'fieldCommonChildCheck'){
                return (
                    <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@ls7hce`}
                    options={[{
                        key: 'fieldCommonCheck',
                        showname: getLabel('513505','公共选择框')
                    }, {
                        key: 'fieldCommonChildCheck',
                        showname: getLabel('513506','公共选择框子项')
                    }]}
                    style={style}
                    disabled={disabled}
                    value={value.value}
                />
                )
            } else {
                return (
                    <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@2mgx3r`}
                        mask
                        type={'browserTypeList'}
                        inputStyle={style}
                        {...restProps}
                        viewAttr={disabled ? 1 : 3}
                        hasBorder={true}
                        replaceDatas={value.valueObj ? value.valueObj : value.value && [{ id: value.value, name: value.valueSpan }]}
                    />
                )
            }
            
        } else if (htmlType === HtmlType.Upload) {
            return (
                <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@w854st`}
                    options={[{
                        key: 'file',
                        showname: getLabel('514588','上传文件')
                    }, {
                        key: 'image',
                        showname: getLabel('513507','上传图片')
                    }]}
                    {...props}
                />
            )
        }
    }
}